package com.pxene.dmp.test.mr.matchUer1;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;

import com.pxene.dmp.constant.BaseConstant;

public class MatchUser1Task  extends Configuration implements Tool{
	
	@Override
	public void setConf(Configuration conf) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Configuration getConf() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int run(String[] args) throws Exception {
		Configuration conf=new Configuration();
		FileSystem hadoopFs=FileSystem.get(conf);
		conf.set("mapreduce.job.queuename", "root.vendor.ven3"); //设置队列
		Job job = Job.getInstance(conf);
		
		job.setJobName("getSearchWord");
		job.setJarByClass(MatchUser1Task.class);
		
		job.setMapperClass(MatchUser1Mapper.class);
		job.setNumReduceTasks(0);
		
		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(Text.class);
		
//		String path1="/daas/bstl/dpiqixin/chongqing/20160509";
//		String path2="/daas/bstl/dpiqixin/jiangxi/20160509";
		String path3="/daas/bstl/dpiqixin/sichuan/20160509";
//		String path6="/daas/bstl/dpiqixin/chongqing_4G/20160509";
//		String path7="/daas/bstl/dpiqixin/jiangxi_4G/20160509";
//		String path8="/daas/bstl/dpiqixin/sichuan_4G/20160509";
//		SequenceFileInputFormat.addInputPaths(job, path1);
//		SequenceFileInputFormat.addInputPaths(job, path2);
//		SequenceFileInputFormat.addInputPaths(job, path7);
//		SequenceFileInputFormat.addInputPaths(job, path6);
//		SequenceFileInputFormat.addInputPaths(job, path7);
//		SequenceFileInputFormat.addInputPaths(job, path8);
//		SequenceFileInputFormat.addInputPaths(job, path4);
//		SequenceFileInputFormat.addInputPaths(job, path5);
		
//		String path9="/daas/bstl/dpiqixin/sichuan/20160509/MBLDPI3G.2016050920*lzo_deflate";
//		path9="/daas/bstl/dpiqixin/sichuan/20160509/MBLDPI3G.2016050923_10.1462807815068.lzo_deflate";
//		FileStatus[] statuses3g = hadoopFs.globStatus(new Path(path9));
//		for (FileStatus status : statuses3g) {
//			String path = status.getPath().toString();
//			FileInputFormat.addInputPaths(job, path);
//		}
		
		FileInputFormat.addInputPaths(job, path3);
		
		job.setInputFormatClass(SequenceFileInputFormat.class);
		
		Path out=new Path("/user/vendorwins/chenjinghui/word3/");
		FileOutputFormat.setOutputPath(job, out);
		FileSystem fs=FileSystem.get(conf);
		if(fs.exists(out)){
			fs.delete(out, true);
		}
		return job.waitForCompletion(true)==true? 0:1;
	}
}